package com.probiz.estore.common.model.content.base;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.common.model.catalog.ContentCategory;
import com.probiz.estore.common.model.content.ContentMedia;
import com.probiz.estore.common.model.content.ContentStat;
import com.probiz.estore.common.model.content.RelatedContent;

/**
 * Content Base Java Bean, base class for the model, mapped directly to database
 * table
 * <p/>
 * Avoid changing this file if not necessary, will be overwritten.
 */
public class ContentTbl extends com.probiz.estore.core.model.BaseObject
        implements Serializable {

    protected Integer contentId;
    protected String contentTitle;
    protected String contentBody;
    protected java.util.Date publishTime;
    protected java.util.Date expiredTime;
    protected String metaKeyword;
    protected String metaDescription;
    protected String imageUrl;
    protected Short displayFlag;
    protected Short validPeriod;
    protected Short isShow;
    protected Short status;
    protected Integer sortOrder;
    protected String sourceName;
    protected String sourceUrl;
    protected String tags;
    protected Date createTime;
    protected Date updateTime;
    protected Integer createBy;
    protected Integer updateBy;
    protected Integer version;
    protected ContentCategory category;
    protected ContentStat contentStat;
    protected Set<ContentMedia> contentMedias = new HashSet<ContentMedia>();
    protected Set<RelatedContent> relatedContents = new HashSet<RelatedContent>(); //关联的文章
    protected Set<RelatedContent> paRelatedContents = new HashSet<RelatedContent>(); //被关联的文章


    /**
     * Default Empty Constructor for class Content
     */
    public ContentTbl() {
        super();
    }

    /**
     * Default Key Fields Constructor for class Content
     *
     * @param in_contentId 文章id
     */
    public ContentTbl(Integer in_contentId) {
        this.setContentId(in_contentId);
    }


    public ContentCategory getCategory() {
        return category;
    }

    public void setCategory(ContentCategory category) {
        this.category = category;
    }
    
    

    public ContentStat getContentStat() {
		return contentStat;
	}

	public void setContentStat(ContentStat contentStat) {
		this.contentStat = contentStat;
	}

	public Set<ContentMedia> getContentMedias() {
		return contentMedias;
	}

	public void setContentMedias(Set<ContentMedia> contentMedias) {
		this.contentMedias = contentMedias;
	}

	
	public Set<RelatedContent> getRelatedContents() {
		return relatedContents;
	}

	public void setRelatedContents(Set<RelatedContent> relatedContents) {
		this.relatedContents = relatedContents;
	}

	public Set<RelatedContent> getPaRelatedContents() {
		return paRelatedContents;
	}

	public void setPaRelatedContents(Set<RelatedContent> paRelatedContents) {
		this.paRelatedContents = paRelatedContents;
	}

	/**
     * * @return Integer
     *
     * @hibernate.id column="contentId" type="java.lang.Integer" generator-class="native"
     */
    public Integer getContentId() {
        return this.contentId;
    }

    /**
     * Set the contentId
     */
    public void setContentId(Integer aValue) {
        this.contentId = aValue;
    }

    /**
     * * @return Integer
     */
    public Integer getCategoryId() {
        return this.getCategory() == null ? null : this.getCategory().getCategoryId();
    }

    /**
     * Set the categoryId
     */
    public void setCategoryId(Integer aValue) {
        if (aValue == null) {
            category = null;
        } else {
            category = new ContentCategory(aValue);
            category.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
        }
    }

    /**
     * * @return String
     *
     * @hibernate.property column="contentTitle" type="java.lang.String" length="64" not-null="true" unique="false"
     */
    public String getContentTitle() {
        return this.contentTitle;
    }

    /**
     * Set the contentTitle
     *
     * @spring.validator type="required"
     */
    public void setContentTitle(String aValue) {
        this.contentTitle = aValue;
    }

    /**
     * * @return String
     *
     * @hibernate.property column="contentBody" type="java.lang.String" length="65535" not-null="false" unique="false"
     */
    public String getContentBody() {
        return this.contentBody;
    }

    /**
     * Set the contentBody
     */
    public void setContentBody(String aValue) {
        this.contentBody = aValue;
    }

    /**
     * * @return java.util.Date
     *
     * @hibernate.property column="publishTime" type="java.util.Date" length="19" not-null="true" unique="false"
     */
    public java.util.Date getPublishTime() {
        return this.publishTime;
    }

    /**
     * Set the publishTime
     *
     * @spring.validator type="required"
     */
    public void setPublishTime(java.util.Date aValue) {
        this.publishTime = aValue;
    }

    /**
     * * @return java.util.Date
     *
     * @hibernate.property column="expiredTime" type="java.util.Date" length="19" not-null="false" unique="false"
     */
    public java.util.Date getExpiredTime() {
        return this.expiredTime;
    }

    /**
     * Set the expiredTime
     */
    public void setExpiredTime(java.util.Date aValue) {
        this.expiredTime = aValue;
    }

    /**
     * * @return String
     *
     * @hibernate.property column="metaKeyword" type="java.lang.String" length="256" not-null="false" unique="false"
     */
    public String getMetaKeyword() {
        return this.metaKeyword;
    }

    /**
     * Set the metaKeyword
     */
    public void setMetaKeyword(String aValue) {
        this.metaKeyword = aValue;
    }

    /**
     * * @return String
     *
     * @hibernate.property column="metaDescription" type="java.lang.String" length="256" not-null="false" unique="false"
     */
    public String getMetaDescription() {
        return this.metaDescription;
    }

    /**
     * Set the metaDescription
     */
    public void setMetaDescription(String aValue) {
        this.metaDescription = aValue;
    }

    /**
     * * @return String
     *
     * @hibernate.property column="imageUrl" type="java.lang.String" length="255" not-null="false" unique="false"
     */
    public String getImageUrl() {
        return this.imageUrl;
    }

    /**
     * Set the imageUrl
     */
    public void setImageUrl(String aValue) {
        this.imageUrl = aValue;
    }

    /**
     * * @return Short
     *
     * @hibernate.property column="displayFlag" type="java.lang.Short" length="5" not-null="false" unique="false"
     */
    public Short getDisplayFlag() {
        return this.displayFlag;
    }

    /**
     * Set the displayFlag
     */
    public void setDisplayFlag(Short aValue) {
        this.displayFlag = aValue;
    }


    public Short getValidPeriod() {
        return validPeriod;
    }

    public void setValidPeriod(Short validPeriod) {
        this.validPeriod = validPeriod;
    }

    public Short getIsShow() {
        return isShow;
    }

    public void setIsShow(Short isShow) {
        this.isShow = isShow;
    }

    /**
     * * @return Short
     *
     * @hibernate.property column="status" type="java.lang.Short" length="5" not-null="true" unique="false"
     */
    public Short getStatus() {
        return this.status;
    }

    /**
     * Set the status
     *
     * @spring.validator type="required"
     */
    public void setStatus(Short aValue) {
        this.status = aValue;
    }

    /**
     * * @return Integer
     *
     * @hibernate.property column="sortOrder" type="java.lang.Integer" length="10" not-null="true" unique="false"
     */
    public Integer getSortOrder() {
        return this.sortOrder;
    }

    /**
     * Set the sortOrder
     *
     * @spring.validator type="required"
     */
    public void setSortOrder(Integer aValue) {
        this.sortOrder = aValue;
    }

    /**
     * * @return String
     *
     * @hibernate.property column="sourceName" type="java.lang.String" length="32" not-null="false" unique="false"
     */
    public String getSourceName() {
        return this.sourceName;
    }

    /**
     * Set the sourceName
     */
    public void setSourceName(String aValue) {
        this.sourceName = aValue;
    }

    /**
     * * @return String
     *
     * @hibernate.property column="sourceUrl" type="java.lang.String" length="255" not-null="false" unique="false"
     */
    public String getSourceUrl() {
        return this.sourceUrl;
    }

    /**
     * Set the sourceUrl
     */
    public void setSourceUrl(String aValue) {
        this.sourceUrl = aValue;
    }
    

    public String getTags() {
		return tags;
	}

	public void setTags(String tags) {
		this.tags = tags;
	}

	/**
     * * @return java.util.Date
     *
     * @hibernate.property column="createTime" type="java.util.Date" length="19" not-null="true" unique="false"
     */
    public java.util.Date getCreateTime() {
        return this.createTime;
    }

    /**
     * Set the createTime
     *
     * @spring.validator type="required"
     */
    public void setCreateTime(java.util.Date aValue) {
        this.createTime = aValue;
    }

    /**
     * * @return java.util.Date
     *
     * @hibernate.property column="updateTime" type="java.util.Date" length="19" not-null="true" unique="false"
     */
    public java.util.Date getUpdateTime() {
        return this.updateTime;
    }

    /**
     * Set the updateTime
     *
     * @spring.validator type="required"
     */
    public void setUpdateTime(java.util.Date aValue) {
        this.updateTime = aValue;
    }

    /**
     * * @return Integer
     *
     * @hibernate.property column="createBy" type="java.lang.Integer" length="10" not-null="false" unique="false"
     */
    public Integer getCreateBy() {
        return this.createBy;
    }

    /**
     * Set the createBy
     */
    public void setCreateBy(Integer aValue) {
        this.createBy = aValue;
    }

    /**
     * * @return Integer
     *
     * @hibernate.property column="updateBy" type="java.lang.Integer" length="10" not-null="false" unique="false"
     */
    public Integer getUpdateBy() {
        return this.updateBy;
    }

    /**
     * Set the updateBy
     */
    public void setUpdateBy(Integer aValue) {
        this.updateBy = aValue;
    }

    /**
     * * @return Integer
     *
     * @hibernate.property column="version" type="java.lang.Integer" length="10" not-null="true" unique="false"
     */
    public Integer getVersion() {
        return this.version;
    }

    /**
     * Set the version
     *
     * @spring.validator type="required"
     */
    public void setVersion(Integer aValue) {
        this.version = aValue;
    }

    /**
     * @see java.lang.Object#equals(Object)
     */
    public boolean equals(Object object) {
        if (!(object instanceof ContentTbl)) {
            return false;
        }
        ContentTbl rhs = (ContentTbl) object;
        return new EqualsBuilder()
                .append(this.contentId, rhs.contentId)
                .append(this.contentTitle, rhs.contentTitle)
                .append(this.publishTime, rhs.publishTime)
                .append(this.expiredTime, rhs.expiredTime)
                .append(this.metaKeyword, rhs.metaKeyword)
                .append(this.metaDescription, rhs.metaDescription)
                .append(this.imageUrl, rhs.imageUrl)
                .append(this.displayFlag, rhs.displayFlag)
                .append(this.status, rhs.status)
                .append(this.sortOrder, rhs.sortOrder)
                .append(this.sourceName, rhs.sourceName)
                .append(this.sourceUrl, rhs.sourceUrl)
                .append(this.createTime, rhs.createTime)
                .append(this.updateTime, rhs.updateTime)
                .append(this.createBy, rhs.createBy)
                .append(this.updateBy, rhs.updateBy)
                .append(this.version, rhs.version)
                .isEquals();
    }

    /**
     * @see java.lang.Object#hashCode()
     */
    public int hashCode() {
        return new HashCodeBuilder(-82280557, -700257973)
                .append(this.contentId)
                .append(this.contentTitle)
                .append(this.contentBody)
                .append(this.publishTime)
                .append(this.expiredTime)
                .append(this.metaKeyword)
                .append(this.metaDescription)
                .append(this.imageUrl)
                .append(this.displayFlag)
                .append(this.status)
                .append(this.sortOrder)
                .append(this.sourceName)
                .append(this.sourceUrl)
                .append(this.createTime)
                .append(this.updateTime)
                .append(this.createBy)
                .append(this.updateBy)
                .append(this.version)
                .toHashCode();
    }

    /**
     * @see java.lang.Object#toString()
     */
    public String toString() {
        return new ToStringBuilder(this)
                .append("contentId", this.contentId)
                .append("contentTitle", this.contentTitle)
                .append("contentBody", this.contentBody)
                .append("publishTime", this.publishTime)
                .append("expiredTime", this.expiredTime)
                .append("metaKeyword", this.metaKeyword)
                .append("metaDescription", this.metaDescription)
                .append("imageUrl", this.imageUrl)
                .append("displayFlag", this.displayFlag)
                .append("status", this.status)
                .append("sortOrder", this.sortOrder)
                .append("sourceName", this.sourceName)
                .append("sourceUrl", this.sourceUrl)
                .append("createTime", this.createTime)
                .append("updateTime", this.updateTime)
                .append("createBy", this.createBy)
                .append("updateBy", this.updateBy)
				.append("version", this.version)
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "contentId";
	}

	/**
	 * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return contentId;
	}
}